//
//  CompanyPositionViewController.m
//  Fangmm
//
//  Created by 阮琦 on 16/3/4.
//  Copyright © 2016年 com.fangmm. All rights reserved.
//

#import "CompanyPositionViewController.h"

#import "ACMacros.h"
#import "User.h"
#import "Utility.h"
#import "Constants.h"

#import <MobClick.h>

@interface CompanyPositionViewController ()

@end

@implementation CompanyPositionViewController

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [MobClick beginLogPageView:@"公司职位页"];
}
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [MobClick endLogPageView:@"公司职位页"];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self configureNavigationBar];
    if (!([[User sharedUser].company isEqual:@"未完善"] || [User sharedUser].company == nil)) {
        self.companyLabel.text = [User sharedUser].company;
    }
    if (!([[User sharedUser].companyMail isEqual:@"未完善"] || [User sharedUser].companyMail == nil)) {
        self.companyMailLabel.text = [User sharedUser].companyMail;
    }
    if (!([[User sharedUser].profession isEqual:@"未完善"] || [User sharedUser].profession == nil)) {
        self.professionLabel.text = [User sharedUser].profession;
    }
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
#pragma mark - Configuring the view’s layout behavior
- (void)configureNavigationBar {
    self.title = @"公司 - 职业";
    self.navigationItem.hidesBackButton = true;
    UIImage *backImage = [[UIImage imageNamed:@"back-18-36"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIBarButtonItem *leftBarButton = [[UIBarButtonItem alloc]initWithImage:backImage style:UIBarButtonItemStyleDone target:self action:@selector(clickToPopBack)];
    self.navigationItem.leftBarButtonItem = leftBarButton;
    
    UIBarButtonItem *rightBarButton = [[UIBarButtonItem alloc]initWithTitle:@"完成" style:UIBarButtonItemStyleDone target:self action:@selector(clickToDone)];
    [rightBarButton setTintColor:RGBACOLOR(119, 119, 119, 1)];
    self.navigationItem.rightBarButtonItem = rightBarButton;
}


#pragma mark - Triggering Methods
- (void)clickToPopBack {
    [self.navigationController popViewControllerAnimated:true];
}

- (void)clickToDone {
    User *user = [User sharedUser];
    user.company = self.companyLabel.text;
    user.profession = self.professionLabel.text;
    user.companyMail = self.companyMailLabel.text;
    [Utility setObject:user key:kUser];
    [self.navigationController popViewControllerAnimated:true];
}

@end
